home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xfig.idb / usr / freeware / src / xfig / transfig.3.1.2 / fig2dev / free.c.z / free.c
Encoding:
C/C++ Source or Header  |  1997-09-09  |  3.5 KB  |  151 lines

  1. /*
  2.  * TransFig: Facility for Translating Fig code
  3.  * Copyright (c) 1985 Supoj Sutantavibul
  4.  * Copyright (c) 1991 Micah Beck
  5.  *
  6.  * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  7.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  8.  * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  9.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  10.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  11.  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  12.  * PERFORMANCE OF THIS SOFTWARE.
  13.  *
  14.  * The X Consortium, and any party obtaining a copy of these files from
  15.  * the X Consortium, directly or indirectly, is granted, free of charge, a
  16.  * full and unrestricted irrevocable, world-wide, paid up, royalty-free,
  17.  * nonexclusive right and license to deal in this software and
  18.  * documentation files (the "Software"), including without limitation the
  19.  * rights to use, copy, modify, merge, publish, distribute, sublicense,
  20.  * and/or sell copies of the Software, and to permit persons who receive
  21.  * copies from any such party to do so, with the only requirement being
  22.  * that this copyright notice remain intact.  This license includes without
  23.  * limitation a license to do the foregoing actions under any patents of
  24.  * the party supplying this software to the X Consortium.
  25.  */
  26.  
  27. #include <stdio.h>
  28. #include <math.h>
  29. #include "fig2dev.h"
  30. #include "object.h"
  31.  
  32. free_arc(list)
  33. F_arc    **list;
  34. {
  35.     F_arc    *a, *arc;
  36.  
  37.     for (a = *list; a != NULL;) {
  38.         arc = a;
  39.         a = a->next;
  40.         if (arc->for_arrow) free((char*)arc->for_arrow);
  41.         if (arc->back_arrow) free((char*)arc->back_arrow);
  42.         free((char*)arc);
  43.         } 
  44.     *list = NULL;
  45.     }
  46.  
  47. free_compound(list)
  48. F_compound    **list;
  49. {
  50.     F_compound    *c, *compound;
  51.  
  52.     for (c = *list; c != NULL;) {
  53.         compound = c;
  54.         c = c->next;
  55.         free_arc(&compound->arcs);
  56.         free_compound(&compound->compounds);
  57.         free_ellipse(&compound->ellipses);
  58.         free_line(&compound->lines);
  59.         free_spline(&compound->splines);
  60.         free_text(&compound->texts);
  61.         free((char*)compound);
  62.         } 
  63.     *list = NULL;
  64.     }
  65.  
  66. free_ellipse(list)
  67. F_ellipse    **list;
  68. {
  69.     F_ellipse    *e, *ellipse;
  70.  
  71.     for (e = *list; e != NULL;) {
  72.         ellipse = e;
  73.         e = e->next;
  74.         free((char*)ellipse);
  75.         } 
  76.     *list = NULL;
  77.     }
  78.  
  79. free_line(list)
  80. F_line    **list;
  81. {
  82.     F_line    *l, *line;
  83.  
  84.     for (l = *list; l != NULL;) {
  85.         line = l;
  86.         l = l->next;
  87.         free_linestorage(line);
  88.         } 
  89.     *list = NULL;
  90.     }
  91.  
  92. free_text(list)
  93. F_text    **list;
  94. {
  95.     F_text    *t, *text;
  96.  
  97.     for (t = *list; t != NULL;) {
  98.         text = t;
  99.         t = t->next;
  100.         cfree(text->cstring);
  101.         free((char*)text);
  102.         } 
  103.     *list = NULL;
  104.     }
  105.  
  106. free_spline(list)
  107. F_spline    **list;
  108. {
  109.     F_spline    *s, *spline;
  110.  
  111.     for (s = *list; s != NULL;) {
  112.         spline = s;
  113.         s = s->next;
  114.         free_splinestorage(spline);
  115.         }
  116.     *list = NULL;
  117.     }
  118.  
  119. free_splinestorage(s)
  120. F_spline      *s;
  121. {
  122.         F_point        *p, *q;
  123.         F_control    *a, *b;
  124.  
  125.         for (p = s->points; p != NULL; p = q) {
  126.             q = p->next;
  127.             free((char*)p);
  128.             }
  129.         for (a = s->controls; a != NULL; a = b) {
  130.             b = a->next;
  131.             free((char*)a);
  132.             }
  133.     if (s->for_arrow) free((char*)s->for_arrow);
  134.     if (s->back_arrow) free((char*)s->back_arrow);
  135.         free((char*)s);
  136.         }
  137.  
  138. free_linestorage(l)
  139. F_line    *l;
  140. {
  141.     F_point    *p, *q;
  142.  
  143.     for (p = l->points; p != NULL; p = q) {
  144.         q = p->next;
  145.         free((char*)p);
  146.         }
  147.     if (l->for_arrow) free((char*)l->for_arrow);
  148.     if (l->back_arrow) free((char*)l->back_arrow);
  149.     free((char*)l);
  150.     }
  151.